<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
    <div id='app'>
        <input type="text" v-model.number='num1'>
        <select v-model='opt'>
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
        </select>
        <input type="text" v-model.number='num2'>
        <button @click='result'>计算</button>
        <span>计算结果:{{sum}}</span>
    </div>
    <script type='text/javascript'>
        var vm = new Vue({
            el: '#app',
            data: {
                num1: '',
                num2: '',
                sum: '',
                opt: '+'
            },
            methods: {
                result() {
                    switch (this.opt) {
                        case '+':
                            this.sum = this.num1 + this.num2
                            break;
                        case '-':
                            this.sum = this.num1 - this.num2
                            break;
                        case '*':
                            this.sum = this.num1 * this.num2
                            break;
                        case '/':
                            this.sum = this.num1 / this.num2
                            break;
                    }
                }
            }
        });
    </script>
</body>

</html>